﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

namespace Server.Utils.JSON
{
    public class JSONObject : Dictionary<string, object>
    {
    }

    public static class JSONUtils
    {
        public static JSONObject Decode(string str)
        {
            JSONObject obj = null;

            try
            {
                JSONDecoder decoder = new JSONDecoder(str);
                obj = decoder.GetValue();
            }
            catch (JSONParseException)
            {
            	
            }

            return obj;
        }

        public static string Encode(JSONObject jsonObj)
        {
            string str = null;

            try
            {
                JSONEncoder encoder = new JSONEncoder(jsonObj);
                str = encoder.GetString();
            }
            catch (JSONParseException)
            {
            }

            return str;
        }
    }
}
